home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 24
/
024.d81
/
t.perfect input
< prev
next >
Wrap
Text File
|
2022-08-26
|
6KB
|
424 lines
PERFECT INPUT
by
Bennett Cookson, Jr.
COMMODORE MICROCOMPUTERS MAGAZINE
May/June, 1986
p. 103
PERFECT INPUT adds commands to BASIC
that help overcome the INPUT
statement's limitations. By running
this program before you write your
programs, you will be able to use
commas and colons in your statements,
to redefine the keyboard, and to have
full cursor movement within a set
range. And those are just SOME of
the features of PERFECT INPUT.
Keep in mind that if you do write a
program using the PERFECT INPUT
commands, you must always load and run
PERFECT INPUT before you run a program
that uses its commands.
PERFECT INPUT COMMANDS
INPUT A$
INPUT"PROMPT";B$
When the PERFECT INPUT statement is
used normally, the "?" prompt is gone.
Commas and colons that would normally
elicit an ?EXTRA IGNORED message are
accepted like any other character.
Note that commas and colons are
accepted only into string variables,
not numeric variables. This means
that you cannot use "INPUT A,B", but
you can use "INPUT A$,B$" to input
numbers.
Also, cursor movement is limited to
a 79-character range. The user still
has full cursor movement, but the
cursor seems to hit a barrier before
it gets out of range.
INPUT\10,A$
INPUT\20,"PROMPT",X$
This syntax allows the programmer to
control the number of characters a
user can type in by setting the
cursor range. Putting the English
pound sign before the line number
will cause it to be read as "limit".
The limit can range from 1 to 79;
anything larger will cause an ILLEGAL
QUANTITY error.
INPUT 200,A$
This syntax provides an exit from
INPUT. When the user presses
a certain key (definable to any key),
BASIC will GOTO the line specified in
the INPUT statement. (The "certain
key" is defined by the DEFine command,
which will be explained later.) With
this command, for example, your
program's user could escape from an
INPUT and go back to a menu without
affecting any variables.
INPUT 15,400,"PROMPT";N
The above features can be used
together. The limit comes first, then
the exit line number. If there is a
prompt string, it always comes last,
just before the variable.
AT x,y
The AT command allows you to
position the cursor anywhere on the
screen by giving the X and Y
coordinates. X represents the
horizontal position (0-39), Y the
vertical position (0-24). The values
for X and Y may be expressed in any
form. These are some examples of how
the AT command is used:
AT 5,7:PRINT"position 5,7"
AT X,Y:INPUT B$
AT J-5+G,INT(W):PRINT" x marks the
spot"
-------
THE DEFine COMMAND
The DEF key command allows you to
redefine any of the keys except the
SHIFT, CONTROL, COMMODORE, RUN/STOP,
and RESTORE keys. For example,
DEF"A=B,R=13,133=F"
changes the "A" key to "B", the "R"
key to CHR$(13), and CHR$(133) to "F".
Because the DEFine key routine works
deep inside the operating system, if
you changed "R" to CHR$(13) (RETURN),
R would act like the RETURN key in all
cases.
The DEFinition list must be written
as a string in quotes or a string
variable. All characters except
numbers, apostrophes, and back arrows
are considered literally as the
character to DEFine.
Numbers, however, are considered
ASCII values and to specify a number
as a literal character you must place
an apostrophe just before it. For
example, 5 would mean CHR$(5), while
'5 means the character "5".
A range of characters can be used
with this command. For example:
DEF"91-255=0"
will set all characters with an ASCII
value of 91 through 255 to zero,
thereby disabling all of those keys.
You would use a command like this if
you wanted to disable all graphics
keys.
Another form of the command can
look like this:
DEF"1-255=0,A-Z=_"
The first part of this line disables
all keys; the second part restores
the A to Z keys to normal. The left
arrow key means "restore to normal".
The escape key that exits from an
INPUT statement can be any key defined
as CHR$(1). For example,
DEF"133=1"
will define F1 as the escape key.
Also, any key defined as CHR$(2) will
act as an erase key, which erases the
character under the cursor.
The DEF command by itself will
reset the keyboard to normal.
RUN/STOP-RESTORE will also reset the
keyboard, but will not disable the
DEFine key or other commands. As an
added feature,the keyboard can also
be reset with the END command or if an
error occurs in the program-- making
it easier to edit lines. If you do
not want the keyboard to reset, you
can remove the two relevant lines
from the loader program with REMs that
say "reset if error" and "reset if
end".
DEMO PROGRAM
Cookson has added a demo program
that shows some of PERFECT INPUT's
features. Before running the demo,
first load and run PERFECT INPUT, then
load and run the demo program.
Lines 70-86 show how to create and
combine present strings. For example,
once you have set NUMKEY$ to define a
numeric keypad (line 80), you can use
DEF NUMKEY$, which is easier than
defining keys one by one. In line 72,
NOKEY$ will disable all keys. With
this method, you can disable all keys
and then activate only the keys you
want. Also, notice how the comma is
used in line 80 when linking strings.
Lines 100-150 print a box on the
screen and allow the user to fill in
the box, but not move the cursor out
of the box. Notice that the DELETE
key has been disabled. Also, it is a
good idea to disable the quote mark
key, because the quote mode can cause
problems in an INPUT statement.
Lines 450-460 show that the DEF
command can be used easily with the
GET statement, and lines 500-680 show
that the DEF command makes it easy to
use function keys. Notice that the
function keys are converted to numbers
that can be used with an ON GOSUB
command. And lines 800-850 show how
the escape key can be used to cause
BASIC to jump out of an INPUT
STATEMENT.
NOTE: Because of the nature of this
program, it cannot be run from the
Loadstar operating system. Press
RUN/STOP RESTORE and then type:
LOAD"PERFECT INPUT",8
RUN
Then to run the demo type:
LOAD"INPUT DEMO",8
RUN
Study a listing of the demo to see
how useful PERFECT INPUT can be to
your programs.
FILES REQUIRED:
PERFECT INPUT INPUT DEMO
------------<end of text>------------